<?php
namespace app\admin\logic;
use think\facade\Request;
use think\facade\View;
class BrandLogic
{
    public static function getWhere()
    {
        $where=[];
        $whereOr=[];
        $form_get=Request::get();

        if (isset($form_get['recommended'])&&$form_get['recommended']=="1"){
            $where[] = ['recommended','=',"{$form_get['recommended']}"];
            View::assign("recommended",$form_get['recommended']);
        }

        if (isset($form_get['recommended'])&&$form_get['recommended']=="0"){
            $where[] = ['recommended','=',"{$form_get['recommended']}"];
        }

        if (isset($form_get['keywords'])){
            $where[] = ['brand_name','like','%'."{$form_get['keywords']}".'%'];
            View::assign('keywords',$form_get['keywords']);
        }

        if (isset($form_get['if_show'])){

            $str=implode(",",$form_get['if_show']);

            $where[] = ['if_show',"in","{$str}"];
            View::assign('if_show',$form_get['if_show']);
        }
        $is_photo=Request::param("logos",'');
        if (!empty($is_photo) &&count($is_photo) ==1){
            if (in_array(0,$is_photo)){
                $whereOr[] = ['brand_logo','=',null];
                $whereOr[] = ['brand_logo','=',''];
            }
            if (in_array(1,$is_photo)){
                $whereOr[] = ['brand_logo','<>',''];
            }

        }
        return [$where, $whereOr];

    }
}